const CryptoJS = require('crypto-js')   //导入模块

//安装模块：npm install crypto-js
//重新安装：step1：npm cache clean --force  # 清除缓存
//step2:   rm -rf node_modules package-lock.json  # 删除依赖和锁文件（谨慎操作）
//step3:   npm install             # 重新安装


var currentTime = new Date();
function getsign(city){
var year = currentTime.getFullYear();
// console.log(currentTime.getFullYear())
// console.log(currentTime['getFullYear']())   //这上下两种方式相等
var mon = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var hour = currentTime.getHours();
var minute = currentTime.getMinutes();
var second = currentTime.getSeconds();
if (0xa > day) {
    day = '0' + day;
}
if (0xa > mon) {
    mon = '0' + mon;
}
if (0xa > hour) {
    hour = '0' + hour;
}
if (0xa > minute) {
    minute = '0' + minute;
}
if (0xa > second) {
    second = '0' + second;
}
var timeString = year + '' + mon + '' + day + '' + hour + '' + minute + '' + second;
var data = city + '_' + timeString;
let key = CryptoJS['enc']['Utf8']['parse']('5ha5Z7cZ3WNbD3rA');
let iv = CryptoJS['enc']['Utf8']['parse']('AYk98XaiBwCi0Dst');
let encryptData = CryptoJS['AES']['encrypt'](data, key, {
    'mode': CryptoJS['mode']['CBC'],
    'iv': iv,
    'padding': CryptoJS['pad']['Pkcs7']
});
sign  =  encryptData['toString']();
return sign
}
// var month = 202505;
var city = "chongqing";
console.log(getsign(city))